/*
 * @Description: 
 * @Author: zoe
 * @Date: 2024-09-25 10:36:44
 * @LastEditors: rendc
 * @LastEditTime: 2024-09-25 16:56:46
 */
public class Test01String {
    public static void main(String[] args) {
        //创建一个空白的字符串对象
        String str1 = new String();
        //空白的字符串对象不含任何内容
        System.out.println("str1:"+str1);
        //根据字符数组创建字符串对象
        char[] chars = {'a','b','c'};
        String str2 = new String(chars);
        System.out.println("str2:"+str2);
        //根据一个字符串直接创建字符串对象
        String str3 = new String("abc");
        System.out.println("str3:"+str3);
        //直接赋值的方式创建字符串
        String str4 = "Hello";
        System.out.println("str4:"+str4);
        String str5 = "Hello";
        System.out.println("str5:"+str5);
        System.out.println("str4==str5:"+(str4==str5));
        String str6 = new String("Hello").intern();
        System.out.println(str4==str6);
        String str7 = "Hello"+"Hello";
        String str8 = "HelloHello";
        System.out.println(str7==str8);//true
        String str9 = str4+str5;
        //System.out.println(str7==str9);//false
        String str10 = (str4+str5).intern();
        System.out.println(str7==str10);//true
        int str9Length = str9.length();
        System.out.println(str9Length);
        System.out.println(str10.length());
        char[] charArr = str10.toCharArray();
        System.out.println("charArr"+charArr);
        String charStr = new String(charArr);
        System.out.println("charStr" + charStr);
    }
}